//
//  RealNameVC.m
//  BrushFace
//
//  Created by timer_q on 15/12/15.
//  Copyright © 2015年 Zzz. All rights reserved.
//

#import "RealNameVC.h"
#import "MySceneModel.h"
#import "IWillHelper.h"
#import "AlertDialogHelper.h"

@interface RealNameVC ()<UITextFieldDelegate>

@property (nonatomic,strong)MySceneModel *scenceModel;
@end

@implementation RealNameVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    [self.navBar setTitle:@"个人信息"];
//    [self.navBar setLeftBtn:NAV_BAR_LEFT_BTN_TYPE_WHITE];
    // Do any additional setup after loading the view from its nib.
    [self dataInit];
    [self UIConfig];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    if (_type == 0) {
        [self.goVerfify setTitle:@"下一步" forState:UIControlStateNormal];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - dataInit
- (void)UIConfig{
    self.inputName.delegate = self;
    self.inputId.delegate = self;
    [self.goVerfify addTarget:self action:@selector(verfifyFullName) forControlEvents:UIControlEventTouchUpInside];

}
- (void)dataInit{
    [self.navBar setTitle:@"实名认证"];
    [self.navBar setLeftBtn:NAV_BAR_LEFT_BTN_TYPE_BLUE];
    
    _scenceModel = [MySceneModel SceneModel];
}

#pragma mark - action
- (void)verfifyFullName{
    
    if ([self.inputName.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length == 0) {
        [AlertDialogHelper showToast:@"请输入真实姓名"];
        return;
    }
    if (![self.inputId.text validateIdentityCard]) {
        [AlertDialogHelper showToast:@"请输入正确的身份证号"];
        return;
    }
    [_scenceModel user_toFullNamedWithName:self.inputName.text andId:self.inputId.text and:^(BOOL isSuccess) {
        if (isSuccess) {
            [IWillHelper sharedInstance].isRealName = YES;
            [self.navigationController popViewControllerAnimated:YES];
        }else{
            
        }
    }];

}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
